<div class="profile-content-row">
	<?php if(!empty($comments)){
		foreach($comments as $comment){
		?>
		<?php if($comment['media_type']!=''){?>
			<div class="postdata" id="<?=$comment['id']?>">
				<div class="row post">
					<div class="col-xs-12 col-md-4">
						<?php 
						
						if($comment['media_type']=="image"){?>
						<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/media/<?=$comment['media']?>" alt="profile-img" class="img-responsive" />
						<?}elseif($comment['media_type']=="video" && $comment['mediaid']!=''){
						
						echo $this->embedded_video->get_video("https://www.youtube.com/watch?v=".$comment['mediaid'],array('height'=>150,'width'=>200));
						}?>
					</div>
					<div class="col-xs-12 col-md-7">
						<h2 class="mid-bar-heading"><?=$comment['firstname'].' '.$comment['lastname'].'('.$comment['social_user'].')'?>&nbsp;&nbsp;&nbsp;&nbsp;Date : <?=date('m/d/Y h:i A', strtotime($comment['date_added']));?></h2>
						<p class="mid-bar-content"><?=$comment['post_desc']?></p>
					</div>
					<div class="col-xs-12 col-md-1">
						<div class="btn-group zapaction">
							<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
								<span class="caret"></span>
							</button>
							<ul class="dropdown-menu" role="menu">
								<?php if($comment['userid']==$userid){?>
								<li><a href="javascript:void(0)" onclick="removecomments('<?=$comment['id']?>')">Remove</a></li>
								<?}?>
								<li><a href="javascript:void(0)" onclick="hidecomments('<?=$comment['id']?>')">Hide</a></li>
							</ul>
						</div>
					</div>
					<div class="clearfix"></div>
					<div class="col-md-12">
						<a href="javascript:void(0)" class="commentdiv" style="margin-right:10px;">Comment</a>
						<a href="javascript:void(0)" class="sharediv" onclick="sharearticle('share<?=$comment['id']?>')" style="margin-right:10px;">Share</a>
					</div>
				</div>
				<div class="row comments" style="display:none;">
					<div class="col-md-12">
						<?php foreach($comment['comment'] as $usercomment){?>
						<div class="media">
							<a class="pull-left" href="#">
								<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/images/zap/<?php echo $usercomment['photo'] == '' ? DEFAULT_IMG : $usercomment['photo'] ; ?>" alt="Profile-img" class="media-object" height="32" width="32">
							</a>
							<div class="media-body">
								<h5 class="media-heading text-primary"><?=$usercomment['firstname']?></h5>
								<p><?=$usercomment['comments']?></p>
								<p class="text-muted"><?=date('m/d/Y h:i A', strtotime($usercomment['comment_date']));?></p>
							</div>
							<span class="glyphicon glyphicon-remove commentremove"></span>
						</div>
						<?}?>
						<div class="media">
							<a class="pull-left" href="#">
								<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/images/zap/<?php echo $zapmember['photo'] == '' ? DEFAULT_IMG : $zapmember['photo'] ; ?>" alt="Profile-img" class="media-object" height="32" width="32">
							</a>
							<div class="media-body">
								<input type="text" class="form-control" name="comment" onkeyup="postcomment(event,this,'<?=$comment['id']?>');" placeholder="Write a Comment....">
							</div>
						</div>
					</div>
				</div>
				<hr>
				<div class="modal fade" id="share<?=$comment['id']?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<form method="post" action="" id="shareform<?=$comment['id']?>">
							<div class="modal-content">
								<div class="modal-header alert alert-info">
									<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
									<h4 class="modal-title">Share This Article</h4>
								</div>
								<div class="modal-body">
									<div class="row" style="margin-bottom:10px;">
										<div class="col-xs-12 col-md-4">
											<?php if($comment['media_type']=="image"){?>
											<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/media/<?=$comment['media']?>" alt="profile-img" class="img-responsive" />
											<?}?>
										</div>
										<div class="col-xs-12 col-md-7">
											<h2 class="mid-bar-heading">Status Update by <br><?=$comment['firstname'].' '.$comment['lastname'].'('.$comment['social_user'].')'?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date : <?=date('m/d/Y h:i A', strtotime($comment['date_added']));?></h2>
											<p class="mid-bar-content"><?=$comment['post_desc']?></p>
										</div>
									</div>
									<div class="clearfix"></div>
									<div class="row">
										<div class="col-md-12">
											<input type="hidden" name="postid" value="<?=$comment['id']?>">
											<input type="hidden" name="post_desc" value="<?=$comment['post_desc']?>">
											<input type="hidden" name="media" value="<?=$comment['media']?>">
											<input type="hidden" name="media_type" value="<?=$comment['media_type']?>">
											<input type="hidden" name="social_user" value="<?=$comment['social_user']?>">
											<textarea class="form-control" rows="3" name="share_comment" placeholder="Write Something......"></textarea>
										</div>
									</div>
									
								</div>
								<div class="modal-footer">
									<div class="socilaicon" >
										<ul>
											<li>
												<input type="checkbox" class="check" name="facebook" value="Facebook" <?php if(!in_array('Facebook',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/fb-small.png"  alt="facebook" class="img-responsive img-gap"/>
											</li>
											<li>
												<input type="checkbox" class="check" name="youtube" value="Youtube" <?php if(!in_array('Youtube',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/utube-small.png"  alt="Youtube" class="img-responsive img-gap"/>
											</li>	
										</ul>
										<ul>
											<li>
												<input type="checkbox" class="check" name="twitter"  value="Twitter" <?php if(!in_array('Twitter',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/tw-small.png"  alt="Twitter" class="img-responsive img-gap"/>
											</li>
											<li>
												<input type="checkbox" class="check" name="snapchat" value="Snapchat" <?php if(!in_array('Snapchat',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/snapchat-small.png"  alt="Snapchat" class="img-responsive img-gap"/>
											</li>	
										</ul>
										<ul>
											<li>
												<input type="checkbox" class="check" name="instagram"  value="Instagram" <?php if(!in_array('Instagram',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/insta-small.png"  alt="Instagram" class="img-responsive img-gap"/>	
											</li>
											<li>
												<input type="checkbox" class="check" name="tumblr" value="Tumblr" <?php if(!in_array('Tumblr',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/tumblr-small.png"  alt="Tumblr" class="img-responsive img-gap"/>	
											</li>
										</ul>
										<ul>
											<li>
												<input type="checkbox" class="check" name="zap"  value="Zap" >
												<img src="<?php echo base_url(); ?>assets/front/images/zap-small.png"  alt="Zap" class="img-responsive img-gap"/>	
											</li>											
										</ul>
									</div>
									<button type="button" class="btn btn-primary" onclick="postshare('shareform<?=$comment['id']?>')">Share Status</button>
									<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
									<div class="clearfix"></div>
									<h5 style="float:left" class="error"></h5>
									
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
			<?}else{?>
			<div class="postdata" id="<?=$comment['id']?>">
				<div class="row post">
					<div class="col-md-11">
						<h2 class="mid-bar-heading"><?=$comment['firstname'].' '.$comment['lastname'].'('.$comment['social_user'].')'?>&nbsp;&nbsp;&nbsp;&nbsp;Date : <?=date('m/d/Y h:i A', strtotime($comment['date_added']));?></h2>
						<p class="mid-bar-content"><?=$comment['post_desc']?></p>
					</div>
					<div class="col-xs-12 col-md-1">
						<div class="btn-group zapaction">
							<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
								<span class="caret"></span>
							</button>
							<ul class="dropdown-menu" role="menu">
								<?php if($comment['userid']==$userid){?>
								<li><a href="javascript:void(0)" onclick="removecomments('<?=$comment['id']?>')">Remove</a></li>
								<?}?>
								<li><a href="javascript:void(0)" onclick="hidecomments('<?=$comment['id']?>')">Hide</a></li>
							</ul>
						</div>
					</div>
					<div class="clearfix"></div>
					<div class="col-md-12">
						<a href="javascript:void(0)" class="commentdiv" style="margin-right:10px;">Comment</a>
						<a href="javascript:void(0)" class="sharediv" onclick="sharearticle('share<?=$comment['id']?>')" style="margin-right:10px;">Share</a>
					
					</div>
				</div>
				<div class="row comments" style="display:none;">
					<div class="col-md-12">
						<?php foreach($comment['comment'] as $usercomment){?>
						<div class="media">
							<a class="pull-left" href="#">
								<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/images/zap/<?php echo $usercomment['photo'] == '' ? DEFAULT_IMG : $usercomment['photo'] ; ?>" alt="Profile-img" class="media-object" height="32" width="32">
							</a>
							<div class="media-body">
								<h5 class="media-heading text-primary"><?=$usercomment['firstname']?></h5>
								<p><?=$usercomment['comments']?></p>
								<p class="text-muted"><?=date('m/d/Y h:i A', strtotime($usercomment['comment_date']));?></p>
							</div>
							<span class="glyphicon glyphicon-remove commentremove"></span>
						</div>
						<?}?>
						<div class="media">
							<a class="pull-left" href="#">
								<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/images/zap/<?php echo $zapmember['photo'] == '' ? DEFAULT_IMG : $zapmember['photo'] ; ?>" alt="Profile-img" class="media-object" height="32" width="32">
							</a>
							<div class="media-body">
								<input type="text" class="form-control" name="comment" onkeyup="postcomment(event,this,'<?=$comment['id']?>');" placeholder="Write a Comment....">
							</div>
						</div>
					</div>
				</div>
				<hr>
				<div class="modal fade" id="share<?=$comment['id']?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<form method="post" action="" id="shareform<?=$comment['id']?>">
							<div class="modal-content">
								<div class="modal-header alert alert-info">
									<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
									<h4 class="modal-title">Share This Article</h4>
								</div>
								<div class="modal-body">
									<div class="row" style="margin-bottom:10px;">
										
										<div class="col-xs-12 col-md-12">
											<h2 class="mid-bar-heading">Status Update by <br><?=$comment['firstname'].' '.$comment['lastname'].'('.$comment['social_user'].')'?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date : <?=date('m/d/Y h:i A', strtotime($comment['date_added']));?></h2>
											<p class="mid-bar-content"><?=$comment['post_desc']?></p>
										</div>
									</div>
									<div class="clearfix"></div>
									<div class="row">
										<div class="col-md-12">
											<input type="hidden" name="postid" value="<?=$comment['id']?>">
											<input type="hidden" name="post_desc" value="<?=$comment['post_desc']?>">
											<input type="hidden" name="media" value="<?=$comment['media']?>">
											<input type="hidden" name="media_type" value="<?=$comment['media_type']?>">
											<input type="hidden" name="social_user" value="<?=$comment['social_user']?>">
											<textarea class="form-control" rows="3" name="share_comment" placeholder="Write Something......"></textarea>
										</div>
									</div>
									
								</div>
								<div class="modal-footer">
									<div class="socilaicon" >
										<ul>
											<li>
												<input type="checkbox" class="check" name="facebook" value="Facebook" <?php if(!in_array('Facebook',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/fb-small.png"  alt="facebook" class="img-responsive img-gap"/>
											</li>
											<li>
												<input type="checkbox" class="check" name="youtube" value="Youtube" <?php if(!in_array('Youtube',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/utube-small.png"  alt="Youtube" class="img-responsive img-gap"/>
											</li>	
										</ul>
										<ul>
											<li>
												<input type="checkbox" class="check" name="twitter"  value="Twitter" <?php if(!in_array('Twitter',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/tw-small.png"  alt="Twitter" class="img-responsive img-gap"/>
											</li>
											<li>
												<input type="checkbox" class="check" name="snapchat" value="Snapchat" <?php if(!in_array('Snapchat',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/snapchat-small.png"  alt="Snapchat" class="img-responsive img-gap"/>
											</li>	
										</ul>
										<ul>
											<li>
												<input type="checkbox" class="check" name="instagram"  value="Instagram" <?php if(!in_array('Instagram',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/insta-small.png"  alt="Instagram" class="img-responsive img-gap"/>	
											</li>
											<li>
												<input type="checkbox" class="check" name="tumblr" value="Tumblr" <?php if(!in_array('Tumblr',$connected_list)) echo "disabled='disabled'";?>>
												<img src="<?php echo base_url(); ?>assets/front/images/tumblr-small.png"  alt="Tumblr" class="img-responsive img-gap"/>	
											</li>
										</ul>
										<ul>
											<li>
												<input type="checkbox" class="check" name="zap"  value="Zap" >
												<img src="<?php echo base_url(); ?>assets/front/images/zap-small.png"  alt="Zap" class="img-responsive img-gap"/>	
											</li>											
										</ul>
									</div>
									<button type="button" class="btn btn-primary" onclick="postshare('shareform<?=$comment['id']?>')">Share Status</button>
									<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
									<div class="clearfix"></div>
									<h5 style="float:left" class="error"></h5>
									
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
			<?}?> 
		<?}?>
	<?}?>
</div> 
<script type="text/javascript">
	function removecomments(id)
	{
		if (confirm('Delete cannot be undone! Images will remain on the server. Are you sure you want to do this?'))
		{
			$.ajax({
				url: '<?php echo base_url()?>ajax/removecomment/'+id,
				success: function(data) {
					if(data=="deleted")
					{
						$('#'+id).fadeOut( "slow" );
					}
				},
				error: function(xhr, ajaxOptions, thrownError) {
					alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
				}
			});
		}
		else
		{
			return false;
		}
	}
    $(document).ready(function() {
		$('.commentdiv').click( function() {
			$(this).parent().parent().parent().find('.comments').slideToggle();
		});
	});
	function postcomment(ev,obj,cid)
	{
		var comment=obj.value;
		var e = ev || event;
		if(e.keyCode == 13) {
			dataString={ postid: cid, comment: comment };
			$.ajax({
				url: '<?php echo base_url()?>ajax/addcomment',
				data:dataString,
				type: "POST",
				beforeSend: function(){
				},
				success: function(data) {
					obj.value="";
					$("#"+cid).find('.comments > div').prepend(data);
					$("#"+cid).find('.comments > div div:first').slideDown("slow");
				},
				error: function(xhr, ajaxOptions, thrownError) {
					alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
				}
			});
			return false; //prevents form from being submitted.
		}
	}
	function sharearticle(id)
	{
		$('#'+id).modal();
	}
	function postshare(formid)
	{
		//$("#"+formid).submit();
		formdata=$("#"+formid).serialize();
		
		var totalcheckbox=$("#"+formid).find(':checkbox:checked').length;
		if(totalcheckbox == 0)
		{
			$("#"+formid).find(".error").html("Please choose one of checkbox");
			return false;
		}
		$.ajax({
				url: '<?php echo base_url()?>ajax/addshare',
				data:formdata,
				type: "POST",
				beforeSend: function(){
				},
				success: function(data) {
					if(data=="success")
					{
						window.location='<?php echo base_url();?>';
					}
				},
				error: function(xhr, ajaxOptions, thrownError) {
					alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
				}
			});
	}
</script>	   